#ifndef DYN_QUAD_QSIMPSON_H
#define DYN_QUAD_QSIMPSON_H

#include "dyn_quad.h"
#include "dyn_trapzDriver.h"

/*! \author Joey Dumont
 *
 *  \date 2012-10-05
 *
 *  \brief Implements Simpson's rule via an extrapolation of the trapezoid method.
 *
 * Using the trapezoidal rule, it is possible to eliminate a higher order
 * term by combining the results of an integration with 2N points and
 * N points. This is a special case of Richardson's extrapolation.
 * The results are called
 *  \f[
 *      S = \frac{4}{3}S_{2N}-\frac{1}{3}S_N
 *  \f]
 * where \f$S_N\f$ is the application of the trapezoidal rule
 * with \f$N\f$ points.
 */

class qSimpson : public Quad
{
public:
    /*! Constructor defines the basic variables, along
     * with the maximum number of refinements allowed.
     * Since the number of steps is given by
     *  \f$N = 2^{maxIterations-1}\f$, use
     * maxIterations sparingly. */
    qSimpson(Functor& _func,
             double _a,
             double _b,
             double _tol,
             int _maxIterations);

    /*! @name Accessor Functions */
    //@{
    int getMaxIterations(){return maxIterations;}
    void setMaxIterations(int _maxIterations){maxIterations=_maxIterations;}
    //@}

    /*! Re-declared pure virtual function. */
    double doQuadrature();

protected:
    /*! Maximum number of refinments. */
    int maxIterations;
};

#endif // DYN_QUAD_QSIMPSON_H
